From 9f73638d4356268a6d0d6aa38439b2ed0a3f1540 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 9 Oct 2020 20:24:52 -0400 Subject: [PATCH] atspicontext: Implement GetIndexInParent This is needed for ATs to take our tree seriously. --- gtk/a11y/gtkatspicontext.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/gtk/a11y/gtkatspicontext.c b/gtk/a11y/gtkatspicontext.c index 4ed4f97f18..4d24f1a959 100644 --- a/gtk/a11y/gtkatspicontext.c +++ b/gtk/a11y/gtkatspicontext.c @@ -200,6 +200,30 @@ handle_accessible_method (GDBusConnection *connection, g_dbus_method_invocation_return_value (invocation, g_variant_new ("(a(so))", &builder)); } + else if (g_strcmp0 (method_name, "GetIndexInParent") == 0) + { + GtkAccessible *accessible = gtk_at_context_get_accessible (GTK_AT_CONTEXT (self)); + GtkWidget *widget = GTK_WIDGET (accessible); + GtkWidget *parent = gtk_widget_get_parent (widget); + GtkWidget *child; + int idx; + + idx = 0; + for (child = gtk_widget_get_first_child (parent); + child; + child = gtk_widget_get_next_sibling (child)) + { + if (!gtk_widget_get_visible (child)) + continue; + + if (child == widget) + break; + + idx++; + } + + g_dbus_method_invocation_return_value (invocation, g_variant_new ("(i)", idx)); + } } static GVariant * -- 2.30.2